package July;

public class Test08 {
    public static void main(String[] args) {
        System.out.println(toBin(10));
    }

    public static String toBin(int number){
        //十进制转二进制
        StringBuilder sb=new StringBuilder();

        //利用循环不断的除以2的余数
        while (true){
            if (number==0){
             break;
            }
            //获取余数%
            int remaindar=number%2;
            //拼接
            sb.insert(0,remaindar);
            number=number/2;
        }

        return sb.toString();
    }
}
